﻿using CodeCreator;
using CodeCreator.Template;
using CodeTemplate.DbHelper.CoreObj;
using iBing.Common.DbHelper;
using iBing.Common.DbHelper.CoreObj;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeTemplate.CodeEdit
{
    public class ToolForGetJsFields
    {
        public static List<ObjJsField> getJsFields(List<DbField> dbFields, List<TypeMap> typeMap)
        {
            List<ObjJsField> result = new List<ObjJsField>();
            foreach (DbField f in dbFields)
            {
                ObjJsField jf = new ObjJsField();
                jf.IsPk = f.IsPk;
                jf.Field = Tools.DbFile2JavaFieldWidtFirstLower(f.FieldName);
                jf.JavaField = Tools.DbFile2JavaFieldWidtFirstLower(f.FieldName);
                jf.Title = Tools.DbFile2JavaFieldWidtFirstLower(f.FieldName);
                if (Tools.GetTypeMapByDb(typeMap, f.FieldType) != null)
                {
                    jf.Type = Tools.GetTypeMapByDb(typeMap, f.FieldType).JsType;
                }
                jf.Width=100;
                jf.Sortable=true;
                jf.IsUse = true;
                jf.Align="center";
                result.Add(jf);
            }
            return result;
        }
    }
}
